<?php
class Application_Form_Schedule extends Validation_Form
{

  public function init()
  {
  	/*
  	 * data to form
  	 */
  	$scheduleDao = new Application_Model_Dao_Schedule();
  	$schedules = $scheduleDao->getToSelect(); 
  
  	$cathedralDao = new Application_Model_Dao_Cathedral();
  	$cathedrals = $cathedralDao->getToSelect();
  	
  	$roleDao = new Application_Model_Dao_Role();
  	$roles = $roleDao->getToSelect();
        
  	
  	/*
  	 * form
  	 */
    $this->setName("zendForm");
    $this->setMethod('post');
    
	$id = new Zend_Form_Element_Hidden('id');
	$id->addFilter('Int');

    
    $nameSchedule = $this->createElement('text', 'nameSchedule');
    $nameSchedule->setLabel('Skrócona nazwa')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
                new Zend_Validate_Alpha()
            ));
	$subject = new Zend_Form_Element_Select('subject_id');
   	$subject->setLabel('Przedmiot')
   	    		   ->setMultiOptions($schedules)
   	    		   ->setRequired(true)
   	    		   ->addValidator('NotEmpty', true);
    $timeStart = $this->createElement('text', 'timeStart');
    $timeStart->setLabel('Godzina rozpoczęcia')
         ->setRequired(TRUE)
         ->setAttrib('size', 30)
         ->addFilters(array(
            new Zend_Filter_StringTrim(),
            new Zend_Filter_StripNewlines(),
			new Zend_Filter_StripTags()
           ))
         ->addValidators(array(
            new Zend_Validate_NotEmpty(),
            new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
            new Zend_Validate_Alpha()
            ));
    $timeEnd = $this->createElement('text', 'timeEnd');
    $timeEnd->setLabel('Godzina zakończenia')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
                new Zend_Validate_Alpha()
            ));
    $hall = $this->createElement('text', 'hall');
    $hall->setLabel('Sala')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringToLower(),
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_EmailAddress(),
                new Zend_Validate_NotEmpty()
            ));
   $periodicity = $this->createElement('text', 'periodicity');
   $periodicity->setLabel('Cykliczność')
            ->setRequired(true)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringToLower(),
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_StringLength(array('min' => 5, 'max' => 30))
            ));
   $group = $this->createElement('text', 'group');
   $group->setLabel('Rok/grupa')
            ->setRequired(true)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringToLower(),
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
            	new Zend_Validate_Identical(trim($token)),
                new Zend_Validate_NotEmpty()
                
                
            )); 

   	$submit = new Zend_Form_Element_Submit('submit');
	$submit->setAttrib('id', 'submit');
    
    $this->addElements(array(
    	$id,
    	$timeStart,
        $timeEnd,
        $periodicity,
        $hall,
        $subject,
        $nameSchedule,
        $group,
        $submit
        ));
  }


}

	